<script>
	$(document).ready(function() {
		$('#token-input-input_autocomplete_airline').focus();
		setTimeout(function() {
		      // Do something after 5 seconds
				$('#token-input-input_autocomplete_airline').blur();
		}, 10);
		$('#token-input-undefined').focus();
		
		$("#switch_location").click(function() {			
			var itemFrom = $("#fromInput").tokenInputFixed("get");
			var itemTo = $("#toInput").tokenInputFixed("get");
			if (itemFrom[0] == null || itemTo[0] == null){
				return;
			} else {
				$("#toInput").tokenInputFixed("clear");
				$("#fromInput").tokenInputFixed("clear");
				
				if(itemFrom[0].airportName == null && itemTo[0].airportName == null){
// 					alert("in all city");
					$("#toInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemFrom[0].cityCode,
						airportName : itemFrom[0].cityName,
						countryCode : itemFrom[0].countryCode
					});
					$("#fromInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemTo[0].cityCode,
						airportName : itemTo[0].cityName,
						countryCode : itemTo[0].countryCode
					});
				} else if(itemFrom[0].airportName != null && itemTo[0].airportName != null){
// 					alert("in all airport");
					$("#toInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemFrom[0].airportCode,
						airportName : itemFrom[0].airportName,
						countryCode : itemFrom[0].countryCode
					});
					$("#fromInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemTo[0].airportCode,
						airportName : itemTo[0].airportName,
						countryCode : itemTo[0].countryCode
					});
				}else if(itemFrom[0].airportName == null && itemTo[0].airportName != null){
// 					alert("in from is city");
					$("#toInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemFrom[0].cityCode,
						airportName : itemFrom[0].cityName,
						countryCode : itemFrom[0].countryCode
					});
					$("#fromInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemTo[0].airportCode,
						airportName : itemTo[0].airportName,
						countryCode : itemTo[0].countryCode
					});
				}else if(itemFrom[0].airportName != null && itemTo[0].airportName == null){
// 					alert("in from is airport");
					$("#toInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemFrom[0].airportCode,
						airportName : itemFrom[0].airportName,
						countryCode : itemFrom[0].countryCode
					});
					$("#fromInput").tokenInputFixed("add", 			{
						appLocationType: "Airport",
						airportCode : itemTo[0].cityCode,
						airportName : itemTo[0].cityName,
						countryCode : itemTo[0].countryCode
					});
				}
			}
		});
	});
</script>